<template>

	<view class="main">

		<u-navbar :bgColor="bgColor" title="预约记录" placeholder="true" @rightClick="rightClick" :autoBack="true"></u-navbar>
		<image class="ysa" style="width: 100%;height: 600rpx;margin-top: -180rpx;" src="/static/images/ysa.png"></image>

		<view class="info">

			<view class="header">
				<view class="row_a_c">
					<view class="xinga"></view>
					<text class="header-title">我的预约信息</text>
				</view>
			</view>

			<z-paging ref="paging" v-model="orderListData" @query="queryList" usePageScroll>
				<view class="container">
					<view class="card column_c" v-for="(item, index) in orderListData" :key="index">
						<view class="card-content">

							<view class="row_a_c space-between">
								<text class="clinic">{{item.store.name}}</text>
								<text v-if="item.status==1" class="status success center">已预约</text>
								<text v-if="item.status==2" class="status success center">已取消</text>
								<text v-if="item.status==3" class="status success center">已到店</text>
								<text v-if="item.status==4" class="status success center">已完结</text>
							</view>
							<view class="appointment-info">
								<view class="name">预约姓名：{{item.name}}</view>
								<view class="time">计划到店时间：{{item.arrival_at}}</view>
								<view class="phone">预约电话：{{item.phone}}</view>
							</view>

							<u-line margin="20rpx 0"></u-line>

							<text class="note">手机号码为到院就诊凭证，请确保预约电话的准确性。</text>

							<view class="actions">
								<button class="yqbut" @click="toUrlr(item)">查看详情</button>
								<button class="kfbut" @click="makePhoneCall(item.store.contact_phone)">联系客服</button>
							</view>
						</view>
					</view>
				</view>
			</z-paging>

		</view>
	</view>

</template>

<script>
	import api_index from '@/api/index.js';
	import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin';
	export default {
		mixins: [ZPMixin],


		async onShow() {
			// this.orderListtFuc();
		},

		data() {
			return {
				bgColor: 'rgba(0, 31, 63, 0)',
				orderListData: [],
			};
		},
		methods: {

			toUrl(url) {
				this.navTo(url);
			},


			toUrlr(item) {
				let itemStr = encodeURIComponent(JSON.stringify(item));
				uni.navigateTo({
					url: `/pages/zxhd/yyxq?item=${itemStr}`
				});
			},


			//打电话
			makePhoneCall(tel) {
				uni.makePhoneCall({
					phoneNumber: tel, // 这里替换成你想拨打的电话号码
					success: function() {
						console.log('拨打电话成功');
					},
					fail: function(err) {
						console.error('拨打电话失败', err);
					}
				});
			},


			async queryList(pageNo, pageSize) {

				const per = {
					no_page: pageNo,
					page_size: pageSize,

				}




				const res = await api_index.orderList(per);
				if (res.code == 1) {
					this.$refs.paging.complete(res.data.list);
				} else {
					this.$refs.paging.complete(false);
				}

			},


			//预约列表
			// async orderListtFuc() {
			// 	var per = {
			// 		no_page: 1,
			// 		page_size: 10,
			// 	}
			// 	const res = await api_index.orderList(per);

			// 	if (res.code == 1) {
			// 		this.orderListData = res.data.list
			// 		console.log('预约列表', this.orderListData);
			// 	} else {
			// 		this.$util.msg(res.message);
			// 		return;
			// 	}
			// },


		}
	};
</script>

<style scoped lang="scss">
	.main {}

	.info {
		width: 100%;

		min-height: 1000rpx;
		background: #FFFFFF;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
		position: absolute;

		top: 540rpx;
		padding: 50rpx 32rpx 32rpx 32rpx;
	}


	.form-container {
		padding: 20rpx;
		background-color: #ffffff;
		border-radius: 16rpx;
	}

	.header {
		margin-bottom: 20rpx;
	}

	.xinga {
		width: 6rpx;
		height: 24rpx;
		background: #1FA194;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		margin-right: 10rpx;
	}



	.header-title {
		font-size: 28rpx;
		font-weight: bold;
		color: #1CC09B;
	}



	.container {
		padding: 20px;
	}

	.card {
		background-color: #fff;
		border-radius: 8px;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
		margin-bottom: 20px;
	}

	.card-header {
		display: flex;
		justify-content: space-between;
		padding: 10px;
		border-bottom: 1px solid #f0f0f0;
	}

	.status {
		width: 92rpx;
		height: 32rpx;
		background: #1FA194;
		border-radius: 4rpx 4rpx 4rpx 4rpx;


		font-weight: 400;
		font-size: 20rpx;
		color: #FFFFFF;

	}


	.cancelled {
		color: #f44336;
	}

	.card-content {
		width: 686rpx;
		min-height: 400rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 8rpx -2rpx rgba(0, 0, 0, 0.04), 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.03), 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.02);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 32rpx;
	}

	.clinic {
		font-weight: bold;
		font-size: 28rpx;
		color: rgba(0, 0, 0, 0.85);


	}

	.name {

		font-weight: 400;
		font-size: 24rpx;
		color: rgba(0, 0, 0, 0.6);
		margin-bottom: 12rpx;

	}

	.time {

		font-weight: 400;
		font-size: 24rpx;
		color: rgba(0, 0, 0, 0.6);
		margin-bottom: 12rpx;


	}

	.phone {

		font-weight: 400;
		font-size: 28rpx;
		color: #1FA194;
		margin-bottom: 12rpx;



	}

	.appointment-info {
		margin-top: 24rpx;
	}

	.note {

		font-weight: 400;
		font-size: 24rpx;
		color: #1FA194;

	}

	.actions {
		display: flex;
		justify-content: space-between;
		margin-top: 50rpx;
	}

	.yqbut {
		width: 192rpx;
		height: 52rpx;
		border-radius: 26rpx 26rpx 26rpx 26rpx;
		border: 2rpx solid #DCDCDC;


		font-weight: 400;
		font-size: 28rpx;
		color: rgba(0, 0, 0, 0.4);
		line-height: 44rpx;

	}

	.kfbut {
		width: 192rpx;
		height: 52rpx;
		border-radius: 26rpx 26rpx 26rpx 26rpx;
		border: 2rpx solid #91F6E8;


		font-weight: 400;
		font-size: 28rpx;
		color: #27CCBB;
		line-height: 44rpx;


	}
</style>